var myvariable : TDateTime
procedure ScriptEvent (var Value : variant)
var myvariable : TDateTime
begin
myvariable :=Date; //Date function returns the current date
LogInfo('The date is ' +FormatDateTime('dd/mm/yyyy', myvariable));
end
TDateTime data type is used to store date and/or time values. Internally a TDateTime is represented as a floating point number. The integral part of a TDateTime value is the number of days that have passed since 30 Dec 1899. The fractional part of the TDateTime value is the fraction of a 24 hour day that has elapsed, e.g. 0 represents midnight and 0.5 represents noon midday.
Following are some examples of TDateTime values in numeric format and their corresponding dates and times:
Numeric Value | Date and Time |
---|---|
0 | 30 Dec 1899 12:00 am |
2.75 | 1 Jan 1900 6:00 pm |
-1.25 | 29 Dec 1899 6:00 am |
35065 | 1 Jan 1996 12:00 am |
To find the fractional number of days between two dates, simply subtract the two values, unless one of the TDateTime values is negative. Similarly, to increment a date and time value by a certain fractional number of days, add the fractional number to the date and time value if the TDateTime value is positive.
For example, to set a TDateTime variable to (today + 10 days) you can use the script
DateVariable := Date + 10;
When working with negative TDateTime values, computations must handle time portion separately. The fractional part reflects the fraction of a 24-hour day without regard to the sign of the TDateTime value. For example, 6:00 am on 12/29/1899 is –1.25, not –1 + 0.25, which would be –0.75. There are no TDateTime values between –1 and 0.
If a field within a File Definition is specified as DateTime then it will require a display format for it to correctly be read/written to the file